package jacidco;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;


public class ConsultasFrame extends javax.swing.JFrame 
{
    ResultSet rs;

    /** Creates new form ConsultasFrame */
    public ConsultasFrame()
    {
        initComponents();
        
        fillComboBoxNivel();
        fillComboBoxPago();
        
        getRootPane().setDefaultButton(btnConsultaGeneral);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txaArea = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        btnConsultaGeneral = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        cmbNiveles = new javax.swing.JComboBox();
        btnConsultaxNivel = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        btnConsultaCumple = new javax.swing.JButton();
        cmbMes = new javax.swing.JComboBox();
        jPanel7 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        btnConsultaDeudas = new javax.swing.JButton();
        cmbPagos = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        lblTitulo1 = new javax.swing.JLabel();
        lblTitulo = new javax.swing.JLabel();
        btnSalir = new javax.swing.JButton();

        jLabel2.setText("jLabel2");
        jLabel2.setName("jLabel2"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Consultas");
        setResizable(false);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txaArea.setColumns(20);
        txaArea.setFont(new java.awt.Font("Times New Roman", 3, 13));
        txaArea.setRows(5);
        txaArea.setName("txaArea"); // NOI18N
        jScrollPane1.setViewportView(txaArea);

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        btnConsultaGeneral.setText("Consultar");
        btnConsultaGeneral.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnConsultaGeneral.setName("btnConsultaGeneral"); // NOI18N
        btnConsultaGeneral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultaGeneralActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 3, 11));
        jLabel3.setText("Consulta General");
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(btnConsultaGeneral, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(33, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(21, 21, 21)
                .addComponent(btnConsultaGeneral, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel4.setFont(new java.awt.Font("Tahoma", 3, 11));
        jLabel4.setText("Consulta x Nivel");
        jLabel4.setName("jLabel4"); // NOI18N

        cmbNiveles.setName("cmbNiveles"); // NOI18N

        btnConsultaxNivel.setText("Consultar");
        btnConsultaxNivel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnConsultaxNivel.setName("btnConsultaxNivel"); // NOI18N
        btnConsultaxNivel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultaxNivelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(cmbNiveles, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(btnConsultaxNivel, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                .addGap(30, 30, 30))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cmbNiveles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(btnConsultaxNivel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel6.setName("jPanel6"); // NOI18N

        jLabel5.setFont(new java.awt.Font("Tahoma", 3, 11));
        jLabel5.setText("Cumpleaños del Mes");
        jLabel5.setName("jLabel5"); // NOI18N

        btnConsultaCumple.setText("Consultar");
        btnConsultaCumple.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnConsultaCumple.setName("btnConsultaCumple"); // NOI18N
        btnConsultaCumple.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultaCumpleActionPerformed(evt);
            }
        });

        cmbMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));
        cmbMes.setName("cmbMes"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(cmbMes, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel6Layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addComponent(btnConsultaCumple, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(25, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18))))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addComponent(btnConsultaCumple, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel7.setName("jPanel7"); // NOI18N

        jLabel6.setFont(new java.awt.Font("Tahoma", 3, 11));
        jLabel6.setText("Pagos Pendientes");
        jLabel6.setName("jLabel6"); // NOI18N

        btnConsultaDeudas.setText("Consultar");
        btnConsultaDeudas.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnConsultaDeudas.setName("btnConsultaDeudas"); // NOI18N
        btnConsultaDeudas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultaDeudasActionPerformed(evt);
            }
        });

        cmbPagos.setName("cmbPagos"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnConsultaDeudas, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel7Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(cmbPagos, 0, 98, Short.MAX_VALUE)))
                .addGap(15, 15, 15))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(11, 11, 11)
                .addComponent(cmbPagos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(btnConsultaDeudas, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 781, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("General", jPanel1);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jacidco/resources/Logo_Jacidco_mini.png"))); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        lblTitulo1.setFont(new java.awt.Font("Times New Roman", 3, 24));
        lblTitulo1.setText("Consultas");
        lblTitulo1.setName("lblTitulo1"); // NOI18N

        lblTitulo.setFont(new java.awt.Font("Times New Roman", 3, 24));
        lblTitulo.setText("Comunidad Dinamica en Java");
        lblTitulo.setName("lblTitulo"); // NOI18N

        btnSalir.setFont(new java.awt.Font("Tahoma", 3, 11));
        btnSalir.setText("Salir");
        btnSalir.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnSalir.setName("btnSalir"); // NOI18N
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 806, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTitulo1)
                            .addComponent(lblTitulo))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(742, Short.MAX_VALUE)
                .addComponent(btnSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblTitulo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblTitulo1))
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 520, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSalir, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName("General");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnConsultaGeneralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaGeneralActionPerformed
        
        limpiaTextArea();
        consultaGeneral();
        
    }//GEN-LAST:event_btnConsultaGeneralActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        
        Main.goToMenuPrincipal();
        dispose();
        
    }//GEN-LAST:event_btnSalirActionPerformed

    private void btnConsultaxNivelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaxNivelActionPerformed
        
        limpiaTextArea();
        consultaxNivel();
        
    }//GEN-LAST:event_btnConsultaxNivelActionPerformed

    private void btnConsultaCumpleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaCumpleActionPerformed
        
        limpiaTextArea();
        consultaCumple(mes());
        
    }//GEN-LAST:event_btnConsultaCumpleActionPerformed

    private void btnConsultaDeudasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaDeudasActionPerformed
        
        limpiaTextArea();
        consultaPagosPendientes();
        
    }//GEN-LAST:event_btnConsultaDeudasActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultaCumple;
    private javax.swing.JButton btnConsultaDeudas;
    private javax.swing.JButton btnConsultaGeneral;
    private javax.swing.JButton btnConsultaxNivel;
    private javax.swing.JButton btnSalir;
    private javax.swing.JComboBox cmbMes;
    private javax.swing.JComboBox cmbNiveles;
    private javax.swing.JComboBox cmbPagos;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JLabel lblTitulo1;
    private javax.swing.JTextArea txaArea;
    // End of variables declaration//GEN-END:variables

    /**
     * Consulta la totalidad de Afiliados inscritos a la Comunidad
     */
    public void consultaGeneral()
    {
        try 
        {
            Main.bd.conectar();
            rs = Main.bd.consultaGeneral();
            
            rs.next();
            
            txaArea.append("Id\tNombre\tApellido\tInstitucion\t\tCarrera\tCodigo\t\tNivel\n");
            txaArea.append("===================================================================================================\n");
            
            while(rs.next())
            {
                txaArea.append(""+rs.getString("cod_afiliado")+"\t"+rs.getString("primer_nombre")+"\t"+rs.getString("primer_apellido")+"\t"+rs.getString("institucion")+"\t"+rs.getString("carrera")+"\t"+rs.getString("cod_java")+"\t\t"+rs.getString("nivel.nombre")+"\n");
            }
            
            Main.bd.cerrarConexion();
            
        } 
        catch (SQLException ex) 
        {
            Main.mensaje.errorGeneral(ex);
        }
        
    }
    
    
    /**
     * Consulta los afiliados pertenecientes al nivel seleccionado en el comboBox de Niveles
     */
    public void consultaxNivel()
    {
        try 
        {
            String nivel = cmbNiveles.getItemAt(cmbNiveles.getSelectedIndex()).toString();
            
            Main.bd.conectar();
            rs = Main.bd.consultaxNivel(nivel);
            //rs.next();
            
            txaArea.append("Afiliados pertenecientes al nivel "+nivel+"\n\n");
            txaArea.append("Id\tNombre\tApellido\tCodigo\n");
            txaArea.append("===================================================================\n");
            
            while(rs.next())
            {
                txaArea.append(""+rs.getString("cod_afiliado")+"\t"+rs.getString("primer_nombre")+"\t"+rs.getString("primer_apellido")+"\t"+rs.getString("cod_java")+"\n");
            }
            
        } 
        catch (SQLException ex) 
        {
            
        }
    }
    
    
    /**
     * Convierte el nombre del Mes Seleccionado en el ComboBox Mes, a numero del tipo '01'
     * 
     * @return el mes en terminos de numero
     */
    public String mes()
    {
        String Mes = cmbMes.getItemAt(cmbMes.getSelectedIndex()).toString();

        return Mes;
    }
    
    
    /**
     * Consulta el cumpleaños de los afiliados en el mes seleccionado
     * 
     * @param Mes el mes de cumpleaños
     */
    public void consultaCumple(String Mes)
    {
        Main.bd.conectar();
        
        int cap = Main.bd.nextCode("cod_afiliado","afiliado")+1;
        
        Vector fecha = new Vector(cap);

        fecha = Main.bd.cumpleanosMes();
        
        txaArea.append("Cumpleaños Mes de "+cmbMes.getItemAt(cmbMes.getSelectedIndex()).toString()+"\n\n");
        txaArea.append("Codigo\t   Nombre\t   Apellido\t   Cumpleaños\t\tEdad\n");
        txaArea.append("==================================================================================\n");

        for(byte i=0;i<cap-1;i++)
        {
            
            if(fecha.elementAt(i).toString().equals(Mes))
            {
                try 
                {
                    rs = Main.bd.cumpleanosMes(i+1);
                    rs.next();
                    
                    int anoActual = java.util.Calendar.getInstance().get(1);
                    int anoNaci = Integer.parseInt(rs.getString("ano"));
                    short edad = (short)(anoActual - anoNaci);
                    
                    txaArea.append(rs.getString("cod_java")+"\t   "+rs.getString("primer_nombre")+"\t   "+rs.getString("primer_apellido")+"\t   "+rs.getString("dia")+"-"+rs.getString("mes")+"\t\t"+edad+"\n");
                
                } 
                catch (SQLException ex) 
                {
                    Logger.getLogger(ConsultasFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
        
            }
 
                

        }
        Main.bd.cerrarConexion();
    }
    
    
    public void consultaPagosPendientes()
    {
        
        try 
        {
            String nombrePago = cmbPagos.getItemAt(cmbPagos.getSelectedIndex()).toString();
            
            Main.bd.conectar();
            rs = Main.bd.pagosPendientes(nombrePago);
            
            txaArea.append("Codigo\tNombre\tApellido\tSemestre\tPago\tEstado\n");
            txaArea.append("==============================================================================\n");
            
            while(rs.next())
            {
                txaArea.append(rs.getString("cod_java")+"\t"+rs.getString("primer_nombre")+"\t"+rs.getString("primer_apellido")+"\t"+rs.getString("semestre")+"\t"+rs.getString("nombre")+"\t"+rs.getString("estado")+"\n");
            }
            
            
        } 
        catch (SQLException ex) 
        {
            Logger.getLogger(ConsultasFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    /**
     * LLena el Combo Box de Nivel con los nombres de los niveles Disponibles
     */
    public void fillComboBoxNivel()
    {
        Main.bd.conectar();
        
        int cap = Main.bd.nextCode("cod_nivel","nivel")+1;
        
        Vector nombre = new Vector(cap);
        Vector nombre2 = new Vector(cap);
        
        nombre2 = Main.bd.muestraDatosComboBoxes(nombre,"nivel");
        
        for(int i=1;i<cap;i++)
        {
            cmbNiveles.addItem(nombre2.get(i));
        }
        
        Main.bd.cerrarConexion();
    }
    
    /**
     * 
     */
    public void fillComboBoxPago()
    {
        Main.bd.conectar();
        
        int cap = Main.bd.nextCode("cod_pago","pagos")+1;
        
        Vector nombre = new Vector(cap);
        Vector nombre2 = new Vector(cap);
        
        nombre2 = Main.bd.muestraDatosComboBoxes(nombre,"pagos");
        
        for(int i=1;i<cap;i++)
        {
            cmbPagos.addItem(nombre2.get(i));
        }
        
        Main.bd.cerrarConexion();
    }
    
    
    /**
     * Limpia el Area de Impresion
     */
    public void limpiaTextArea()
    {
        txaArea.setText("");
    }

    
    
}
